package exercise;

public class Day03Exercise {
    public static void main(String[] args) {
        System.out.println(5 % 2);//1
        System.out.println(8 % 2);//0
        System.out.println(2 % 8);//2
        System.out.println(6 % 2);//0
        System.out.println(15 % 2);//1

        //单独使用---自增
        int a = 5, b = 5;
        a++;
        ++b;
        System.out.println(a);//6
        System.out.println(b);//6
        //单独使用自家减
        a--;
        --b;
        System.out.println(a);//5
        System.out.println(b);//5
        //被使用自增
        a = 5;
        b = 5;
        int c = a++;
        int d = ++b;
        System.out.println(a);//6
        System.out.println(b);//6
        System.out.println(c);//5
        System.out.println(d);//6
        //被使用自减
        a = 5;
        b = 5;
        c = a--;
        d = --b;
        System.out.println(a);//4
        System.out.println(b);//4
        System.out.println(c);//5
        System.out.println(d);//4

        //关系
        int a1 = 5, a2 = 10, a3 = 5;
        boolean b1 = a2 > a1;
        System.out.println(b1);//true
        System.out.println(a3 < a2);//true
        System.out.println(a1 >= a3);//true
        System.out.println(a2 <= a1);//false
        System.out.println(a2 <= a3);//false
        System.out.println(a2 == a3);//false
        System.out.println(a2 != a3);//true

        //逻辑
        a = 5;
        b = 10;
        c = 5;
        boolean b2 = b >= a && b < c;
        System.out.println(b2);//false
        System.out.println(b <= c && b > a);//false
        System.out.println(a == b && c > b);//false
        System.out.println(b != c && a < b);//true

        System.out.println(b <= c || b > a);//true
        System.out.println(a == b || c > b);//false
        System.out.println(b != c || a < b);//true
        System.out.println(b >= a || b < c);//true

        //赋值
        int c1 = 5;
        c1 += 10;//相当于c1=c1+10
        System.out.println(c1);//15
        c1 *= 2;//相当于a=(int)(a*2)
        System.out.println(c1);//30
        c1 /= 6;//相当于a=(int)(a/6)
        System.out.println(c1);//5
        c1 -= 5;//相当于a=c1-5
        System.out.println(c1);//0

        //字符串
        int age = 38;
        System.out.println("age");//age
        System.out.println(age);//38
        System.out.println("age=" + age);//age=38
        System.out.println("我今年" + age + "岁了");//我今年38岁了

        String name = "奥特曼";
        System.out.println("name=" + name);//name=奥特曼
        System.out.println("大家好我叫" + name);//大家好我叫奥特曼
        System.out.println("大家好我叫" + name + "今年" + age + "岁了，优点是会打怪兽");//大家好我叫奥特曼今年38岁了，优点是会打怪兽

        //演示同化作用
        System.out.println(10 + 20 + "" + 30);//3030
        System.out.println("" + 10 + 20 + 30);//102030
        System.out.println(10 + 20 + 30 + "");//60

        //运算符
        int num = 5;
        int flag = num > 0 ? 1 : -1;
        System.out.println(flag);//1
        int e = 88, t = 9;
        int max = e > t ? e : t;
        System.out.println("max=" + max);//8
        int mai = e < t ? e : t;
        System.out.println(mai);//

        //if分支结构
        //满500打8折:
        double price = 600;//(300.0.500.0)
        if (price >= 500) {
            price *= 0.8;
        }
        System.out.println("实际消费金额：" + price);

        //判断成绩是否合法
        int score = 85;//(70,101)
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法");
        }

        //满500打8折，不满500打9折
        price = 600;
        if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        System.out.println("最终消费金额：" + price);

        //判断成绩合法还是不合法
        score = 101;
        if (price >= 0 && price <= 100) {
            System.out.println("成绩合法");
        } else {
            System.out.println("成绩不合法");
        }

        //满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折
        price = 6000;//(30,560,1800,3000)
        if(price>=2000){
            price *= 0.5;
        }else if(price>=1000){
            price *= 0.7;
        }else if(price>=500){
            price *= 0.8;
        }else{
            price*=0.9;
        }
        System.out.println("最终消费金额："+price);

    }
}
